<template>
  <view class="">
    <u-form-item
      :label="item.label"
      borderBottom
      ref="item1"
      :prop="item.value"
      :required="item.required"
    >
      <!-- <view  >{{ inputValue }}</view> -->
      <view
        @click="!disabled && (show = true)"
        style="flex: 1; padding: 0; min-height: 40rpx"
        ref="formitem"
      >
        {{ showvalue }}
      </view>
      <!-- :class="[value ? 'uni-input-input' : 'select-wrap']" -->
    </u-form-item>
    <!-- datePicker -->
    <!-- <u-datetime-picker
      :show="show"
      v-model="inputValue"
      mode="date"
      @confirm="show = false"
      @cancel="show = false"
    ></u-datetime-picker> -->

    <u-calendar :show="show" mode="range" @confirm="confirm" @close="close"></u-calendar>
  </view>
</template>

<script>
export default {
  mixins: [uni.$u.mpMixin, uni.$u.mixin],
  props: {
    item: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
    data: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
    value: {
      typeof: [String, Number, Boolean, Array, Object],
      default: () => {
        return "";
      },
    },
  },
  data() {
    return {
      // inputValue: "",
      show: false,
    };
  },
  computed: {
    disabled() {
    	this.getParentData("u-form")
				return this.parent.disabled;
    },
    showvalue() {
      if (!this.value || this.value == "0") {
        return "请选择";
      }
      return this.value.join("~");
    },
    inputValue: {
      get() {
        if (!this.value || this.value == "0") {
          return Number(new Date());
        }
        return Number(new Date(Number(this.value)));
      },
      set(val) {
        val = String(val);
        this.$emit("input", val);
        uni.$u.formValidate(this.$refs.formitem, "blur");
      },
    },
  },

  methods: {
    confirm(v){
      this.$emit("input", [v[0],v[v.length-1]]);
      this.show=false
    },
    close(){
      this.show=false
    }
  },
};
</script>

<style scoped lang="scss">
.uni-input-input {
  font-size: 14px !important;
  color: #171a1d !important;
  line-height: 99rpx !important;
  height: 99rpx !important;
  padding-left: 10px;
}

.uni-forms-item__label {
  margin-left: 0;
  font-size: 14px !important;
  color: #171a1d !important;
  line-height: 99rpx !important;
  height: 99rpx !important;
}
</style>
